<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>测试工具</title>
	<link rel="icon" type="image/png" href="img/title.png">
	
	<style type="text/css">
			
	</style>
</head>
<body>
	
	<div id="content" class="over"> 
		<fieldset  align="center">
			<legend align="left">***默认设置***</legend>
			<center>

				<table>
					<tr>
						<td align="right">模型版本选择：</td>
						<td>
							<select name="modidnum" id="modidnum">
								<option value= 0 >ub2024-04-10-01-720p</option>
							</select>
						</td>
					</tr>
					<tr>
						<td align="right">置信度调节:</td>
						<td>
							<input type="range" name="ConfAD" id="ConfAD" min="0" max="100">
						</td>
					</tr>
					<tr>
						<td align="right">灰度调节:</td>
						<td>
							<input type="range" name="Y_filter" id="Y_filter" min="1" max="255">
						</td>
						<td>
							<p id="Y_filter_num">175</p>
						</td>
					</tr>
					<tr>
						<td >
							<input type="button" onclick="EZresetsys()" value="简单重置">
						</td>
						<td>
							<input type="button" onclick="Fullresetsys()" value="完全重置">
						</td>
						<td>
							<input type="button" onclick="reStartSys()" value="重启设备">
						</td>
					</tr>
					<tr>
						<td>
							<p>测试使用网页自带控件传输</p>
							<form method="post" enctype="multipart/form-data" action="/update">
								<input type="file" name="file">
								<input type="submit" value="提交文件">
							</form>
						</td>
					</tr>
					<tr>
						<td align="right">警戒区域预览:</td>
						<td>
							<td><input type="button" id="WarnAreaSwitch_open" value="开启"></td>
							<td><input type="button" id="WarnAreaSwitch_close" value="关闭"></td>
						</td>
					</tr>
					<tr><td></td></tr>
					<tr>
						<td></td>
						<td></td>
						<td><input type="button" onclick="reqdefSetting()" value="设置完成"></td>
					</tr>
				</table>
			</center>
		</fieldset>
	</div>

	

	

	<div>
		<fieldset  align="center">
			<legend align="left">***云台控制***</legend>
			<center>
				<p id = "info_print_test"></p>
				<table>
					<tr>
						<td align="right">预置位:</td>
						<td >
							<input type="text" id="presetpoint">
						</td>
						<td><input type="button" onclick="presetpointSetting(event)" value="设置"></td>
						<td><input type="button" onclick="presetpointSetting(event)" value="调用"></td>
					</tr>
					<tr>
						<td align="right">速度调节:</td>
						<td>
							<input type="range" name="ptzspeed" id="ptzspeed" min="0" max="100">
						</td>
						<td>
							<p id="ptzspeed_num">50</p>
						</td>
					</tr>
					<tr>
						<td><input type="button" id="setPTZleft" value="左转"></td>
						<td><input type="button" id="setPTZup" value="上转"></td>
						<td><input type="button" id="setPTZdown" value="下转"></td>
						<td><input type="button" id="setPTZright" value="右转"></td>
					</tr>
					<tr>
						<td><input type="button" id="setPTZ_sw1" value="爆闪灯"></td>
						<td><input type="button" id="setPTZ_sw2" value="喇叭"></td>
						<td><input type="button" id="setPTZ_sw3" value="天线"></td>
						<td></td>
						<td><input type="button" id="ZoomRatioadd" value="倍率+"></td>
						<td><input type="button" id="ZoomRatiosub" value="倍率-"></td>
					</tr>
					<tr>
						<td align="right">相对角度移动</td>
						<td><input type="text" id="SetAngleRelativeValue" ></td>
						<td></td>
						<td><input type="button" id="set_pan_relative" onclick="SetAngleRelative(event)" value="水平执行"></td>
						<td><input type="button" id="set_tilt_reltive" onclick="SetAngleRelative(event)" value="垂直执行"></td>
					</tr>
					<tr>
						<td align="right">手动模式:</td>
						<td></td>
						<td><input type="button" onclick="setManualmode(event)" value="开启"></td>
						<td><input type="button" onclick="setManualmode(event)" value="关闭"></td>

						<td><input type="button" onclick="draw_autoDetConf_FS(event)" value="开启标定准星"></td>
						<td><input type="button" onclick="draw_autoDetConf_FS(event)" value="关闭标定准星"></td>
					</tr>
					<tr>
						<td><input type="button" id="queryPT" onclick="queryPT()" value="查询角度"></td>
						<td id="queryPT_recv_msg">&nbsp;</td>
						<td></td>
						<td><input type="button" id="set19" onclick="set19()" value="设置19号侦测点"></td>
					</tr>
					<tr>
						<td align="right">跟踪测试:</td>
						<td></td>
						<td><input type="button" onclick="start_ptz_test(event)" value="开"></td>
						<td><input type="button" onclick="start_ptz_test(event)" value="关"></td>
					</tr>
					<!-- <tr>
						<td align="right">滤框开关:</td>
						<td></td>
						<td><input type="button" onclick="filter_frame_switch(event)" value="开"></td>
						<td><input type="button" onclick="filter_frame_switch(event)" value="关"></td>
					</tr> -->
				</table>
			</center>
		</fieldset>
	</div>

	<div>
		<fieldset  align="center">
			<legend align="left">***IR控制***</legend>
			<center>
				<p id = "info_print_test"></p>
				<table>
					<tr>
						<td align="right">亮度调节:</td>
						<td>
							<input type="range" name="IRlm" id="IRlm" min="0" max="255">
						</td>
					</tr>
					<tr>
						<td >&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td></td>
						<td></td>
						<td><input type="button" onclick="openIR()" value="开启"></td>
						<td><input type="button" onclick="closeIR()" value="关闭"></td>
					</tr>
				</table>
			</center>
		</fieldset>
	</div>


	<div>
		<fieldset  align="center">
			<legend align="left">***热成像设置***</legend>
			<center>
				<p id = "info_print_test"></p>
				<table>
					<tr>
						<td align="right">热成像设置:</td>
						<td >
							<select name="SYmodset" id="SYmodset">
								<option value= 0 >更改电压3.3v</option>
								<option value= 1 >更改电压1.8v</option>		
							</select>
							<select name="SYmodset" id="SYmodset">
								<option value= 0 >开启</option>
								<option value= 1 >关闭</option>
							</select>
						</td>
					</tr>
					<tr>
						<td id="TIsetingMsg">&nbsp;</td>
						<td></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
						<td><input type="button" onclick="TiSetting()" value="设置"></td>
						<td><input type="button" onclick="queryTiimg()" value="截图"></td>
					</tr>
				</table>
			</center>
		</fieldset>
	</div>

	<div>
		<fieldset  align="center">
			<legend align="left">***本机信息***</legend>
			<center>
				<p id = "info_print_test"></p>
				<table>
					<tr>
						<td align="right">设备ID:</td>
						<td id="eqid">&nbsp;</td>
					</tr>
					<tr>
						<td align="right">模型版本:</td>
						<td id="MODEL_VERSION">&nbsp;</td>
					</tr>
					<tr>
						<td align="right">软件版本:</td>
						<td id="APP_VERSION">&nbsp;</td>
					</tr>
					<tr>
						<td align="right">云台版本:</td>
						<td id="GIMBAL_VERSION">&nbsp;</td>
					</tr>
				</table>
			</center>
		</fieldset>
	</div>
</body>

<script type="text/javascript" >

		function reqdefSetting(){
            //1.创建异步对象
            let xmlhttp=new XMLHttpRequest();
            //2.绑定事件
            xmlhttp.onreadystatechange=function (){
                if(xmlhttp.readyState==4&&xmlhttp.status==200){
                   let msg=xmlhttp.responseText
                   document.getElementById('ledPwm').value=msg;
                }
            }
            //3.初始化异步对象
            let modidnum=document.getElementById('modidnum').value;
            let ConfAD=document.getElementById('ConfAD').value;
            xmlhttp.open("get","defSetting?modidnum="+modidnum+"&ConfAD="+ConfAD,true);
            //4.发送请求
            xmlhttp.send();
       	}

		document.getElementById('Y_filter').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			let Y_filter=document.getElementById('Y_filter').value;
			document.getElementById('Y_filter_num').innerText=Y_filter;
			xmlhttp.open("get","set_Y_filter?num="+Y_filter,true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('ptzspeed').addEventListener("mouseup",function() {
			let ptzspeed=document.getElementById('ptzspeed').value;
			document.getElementById('ptzspeed_num').innerText=ptzspeed;
		});
		
		   

		function TiSetting(){
            let xmlhttp=new XMLHttpRequest();
            xmlhttp.onreadystatechange=function (){
                if(xmlhttp.readyState==4&&xmlhttp.status==200){
                   let msg=xmlhttp.responseText
                   document.getElementById('TIsetingMsg').innerText=msg;
                }
            }
            let SYmodset=document.getElementById('SYmodset').value;
            xmlhttp.open("get","Tisetting?set_Ti="+SYmodset,true);
            xmlhttp.send();
       	}

		function  queryTiimg(){
            let xmlhttp=new XMLHttpRequest();
            xmlhttp.open("get","queryTiimg",true);
            xmlhttp.send();
       	}


		function EZresetsys(){
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","action/reset?modidnum={netReset: 0, userReset: 0}",true);
            //4.发送请求
            xmlhttp.send();
		}

		function Fullresetsys(){
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","defSetting?modidnum="+modidnum+"&ConfAD="+ConfAD,true);
            //4.发送请求
            xmlhttp.send();
		}

	

		function setManualmode(event){
			const b_value = event.target.value;
			console.log('Button clicked with value:', b_value);

			let xmlhttp=new XMLHttpRequest();
			if(b_value=="开启")
            	xmlhttp.open("get","setManualmode?cmd=1",true);
            else
				xmlhttp.open("get","setManualmode?cmd=2",true);
            //4.发送请求
            xmlhttp.send();
		}

		function draw_autoDetConf_FS(event){
			const b_value = event.target.value;
			// console.log('Button clicked with value:', b_value);

			let xmlhttp=new XMLHttpRequest();
			if(b_value=="开启标定准星")
            	xmlhttp.open("get","draw_autoDetConf_FS?switch=K",true);
            else
				xmlhttp.open("get","draw_autoDetConf_FS?switch=Q",true);
            //4.发送请求
            xmlhttp.send();
		}

		function start_ptz_test(event){
			const b_value = event.target.value;
			console.log('Button clicked with value:', b_value);

			let xmlhttp=new XMLHttpRequest();

			if(b_value=="开")
            	xmlhttp.open("get","defSetting?cmd=1",true);
            else
				xmlhttp.open("get","defSetting?cmd=0",true);
            //4.发送请求
            xmlhttp.send();
		}
		
		// function filter_frame_switch(event){
		// 	const b_value = event.target.value;
		// 	console.log('Button clicked with value:', b_value);

		// 	let xmlhttp=new XMLHttpRequest();

		// 	if(b_value=="开")
        //     	xmlhttp.open("get","defSetting?cmd=19",true);
        //     else
		// 		xmlhttp.open("get","defSetting?cmd=20",true);
        //     //4.发送请求
        //     xmlhttp.send();
		// }
		function reStartSys(){
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","restart",true);
            //4.发送请求
            xmlhttp.send();
		}

		function presetpointSetting(event){
			const b_value = event.target.value;
			console.log('Button clicked with value:', b_value);
            //1.创建异步对象
            let xmlhttp=new XMLHttpRequest();
            //2.绑定事件
            // xmlhttp.onreadystatechange=function (){
            //     if(xmlhttp.readyState==4&&xmlhttp.status==200){
            //        let msg=xmlhttp.responseText
            //        document.getElementById('ledPwm').value=msg;
            //     }
            // }
            //3.初始化异步对象
            let presetpoint=document.getElementById('presetpoint').value;
			if(b_value=="设置")
            	xmlhttp.open("get","setPTZ?cmd=11&param="+presetpoint,true);
            else
				xmlhttp.open("get","setPTZ?cmd=10&param="+presetpoint,true);
			
				//4.发送请求
            xmlhttp.send();
       	}


		   
		document.getElementById('WarnAreaSwitch_open').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","HandleDrawWarningAreaRequest?switch=O",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('WarnAreaSwitch_close').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","HandleDrawWarningAreaRequest?switch=Q",true);
            //4.发送请求
            xmlhttp.send();
		});

		
		document.getElementById('setPTZleft').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			let ptzspeed=document.getElementById('ptzspeed').value;
			xmlhttp.open("get","setPTZ?cmd=3&param="+ptzspeed,true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZright').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			let ptzspeed=document.getElementById('ptzspeed').value;
			xmlhttp.open("get","setPTZ?cmd=4&param="+ptzspeed,true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZup').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			let ptzspeed=document.getElementById('ptzspeed').value;
			xmlhttp.open("get","setPTZ?cmd=1&param="+ptzspeed,true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZdown').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			let ptzspeed=document.getElementById('ptzspeed').value;
			xmlhttp.open("get","setPTZ?cmd=2&param="+ptzspeed,true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZleft').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=9&param=100",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZright').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=9&param=100",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZup').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=9&param=100",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZdown').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=9&param=100",true);
            //4.发送请求
            xmlhttp.send();
		});


		function SetAngleRelative(event){
			const b_value = event.target.value;
			console.log('Button clicked with value:', b_value);

			let xmlhttp=new XMLHttpRequest();
			let value=document.getElementById('SetAngleRelativeValue').value;
			if(b_value=="水平执行")
            	xmlhttp.open("get","setPTZ?cmd=17&param="+value,true);
            else
				xmlhttp.open("get","setPTZ?cmd=18&param="+value,true);
            //4.发送请求
            xmlhttp.send();
		}
		

// =============================辅助开关======================================================
		document.getElementById('setPTZ_sw1').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=12&param=1",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZ_sw1').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=13&param=1",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZ_sw2').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=12&param=2",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZ_sw2').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=13&param=2",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZ_sw3').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=12&param=3",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('setPTZ_sw3').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=13&param=3",true);
            //4.发送请求
            xmlhttp.send();
		});

// =============================辅助开关======================================================
		

		document.getElementById('ZoomRatioadd').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=14",true);
            //4.发送请求
            xmlhttp.send();
		});

		document.getElementById('ZoomRatiosub').addEventListener("mousedown",function() {
			let xmlhttp=new XMLHttpRequest();
			xmlhttp.open("get","setPTZ?cmd=15",true);
            //4.发送请求
            xmlhttp.send();
		});



		function queryPT(){
            let xmlhttp=new XMLHttpRequest();
            xmlhttp.onreadystatechange=function (){
                if(xmlhttp.readyState==4&&xmlhttp.status==200){
                   let msg=xmlhttp.responseText
				   console.log(msg)
                   document.getElementById('queryPT_recv_msg').innerText=msg;
                }
            }
            xmlhttp.open("get","setPTZ?cmd=16",true);
            xmlhttp.send();
       	}

		function  set19(){
            let xmlhttp=new XMLHttpRequest();
            xmlhttp.open("get","autoDetConf?num=19",true);
            xmlhttp.send();
       	}

		
////////////////////////////////////IR设置//////////////////////////////////////////////
		function  openIR(){
            let xmlhttp=new XMLHttpRequest();
            xmlhttp.open("get","setPTZ?cmd=20&param=1",true);
            xmlhttp.send();
       	}

		function  closeIR(){
            let xmlhttp=new XMLHttpRequest();
            xmlhttp.open("get","setPTZ?cmd=20&param=0",true);
            xmlhttp.send();
       	}

		document.getElementById('IRlm').addEventListener("mouseup",function() {
			let xmlhttp=new XMLHttpRequest();
			let IRlm=document.getElementById('IRlm').value;
			xmlhttp.open("get","setPTZ?cmd=21&param="+IRlm,true);
            //4.发送请求
            xmlhttp.send();
		});
		

////////////////////////////////////IR设置//////////////////////////////////////////////
		window.onload = function(){
			let xmlhttp=new XMLHttpRequest();
            xmlhttp.onreadystatechange=function (){
                if(xmlhttp.readyState==4&&xmlhttp.status==200){
                   let json_msg=xmlhttp.responseText;
				   let msg=JSON.parse(json_msg);
                   document.getElementById('APP_VERSION').innerText=msg.APP_VERSION;
				   document.getElementById('GIMBAL_VERSION').innerText=msg.GIMBAL_VERSION;
				   document.getElementById('MODEL_VERSION').innerText=msg.MODEL_VERSION;
                }
            }
            xmlhttp.open("get","queryinfo",true);
            xmlhttp.send();
		}
</script>


</html>

